{include file='Common/header.html'}
<link rel="stylesheet" href="{$smarty.const.STATIC_URL}/statics/font-awesome-4.4.0/css/font-awesome.min.css" />
<link rel="stylesheet" href="{$smarty.const.STATIC_URL}/statics/base.css" />
<link rel="stylesheet" href="{$smarty.const.STATIC_URL}/statics/iCheck-1.0.2/skins/all.css">
<style>
    .modal.in .modal-dialog{
        margin-top: 20%;
        z-index: 10000;
    }
    .modal-backdrop{
        z-index: 0;
    }
    input[type=checkbox], input[type=radio] {
        opacity: 1;
        position: inherit;
        left: -9999px;
        z-index: -1;
        cursor: pointer;
    }

</style>
<div class="page-content">
    <!-- Page Breadcrumb -->
    <div class="page-breadcrumbs">
<div class="bjy-admin-nav"><a href="{$smarty.const.__MODULE__}/Index/index"><i class="fa fa-home"></i> 首页</a> &gt; 菜单管理</div>
<ul id="myTab" class="nav nav-tabs">
    <li class="active"><a href="#home" data-toggle="tab">菜单列表</a></li>
    <li><a href="javascript:;" onclick="add()">添加菜单</a></li>
</ul>
<form action="{$smarty.const.__MODULE__}/Nav/order" method="post">
    <div id="myTabContent" class="tab-content">
        <div class="tab-pane fade in active" id="home">
            <table class="table table-striped table-bordered table-hover table-condensed">
                <tr>
                    <th width="5%">排序</th>
                    <th>菜单名</th>
                    <th>连接</th>
                    <th>控制器</th>
                    <th>icon</th>
                    <th>显示(1)/隐藏(0)</th>
                    <th>操作</th>
                </tr>
                {foreach $data as $v}
                    <tr>
                        <td><input class="form-control" style="width:40px;height:25px;" type="text" name="{$v['id']}"
                                   value="{$v['sort']}"></td>
                        <td>{$v['_name']}</td>
                        <td>{$v['url']}</td>
                        <td>{$v['controller']}</td>
                        <td>{$v['icon']}</td>
                        <td>{$v['status']}</td>
                        <td><a href="javascript:;" navId="{$v['id']}" navName="{$v['name']}"  onclick="add_child(this)">添加子菜单</a>
                            | <a href="javascript:;" navStatus="{$v['status']}" navId="{$v['id']}" navName="{$v['name']}" controller="{$v['controller']}" navMca="{$v['url']}"
                                 navIco="{$v['icon']}" onclick="edit(this)">修改</a> | <a
                                    href="javascript:if(confirm('确定删除？'))location='{$smarty.const.__MODULE__}/Nav/delete/id/{$v.id}'">删除</a>
                        </td>
                    </tr>
                {/foreach}
                <tr>
                    <th><input class="btn btn-success" type="submit" value="排序"></th>
                    <td></td>
                    <td></td>
                </tr>
            </table>
        </div>
    </div>
</form>
<div class="modal fade" id="bjy-add" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times;</button>
                <h4 class="modal-title" id="myModalLabel"> 添加菜单</h4></div>
            <div class="modal-body">
                <form id="bjy-form" class="form-inline" action="{$smarty.const.__MODULE__}/Nav/add" method="post"><input
                        type="hidden" name="pid" value="0">
                    <table class="table table-striped table-bordered table-hover table-condensed">
                        <tr>
                            <th width="12%">菜单名：</th>
                            <td><input class="form-control" type="text" name="name"></td>
                        </tr>
                        <tr>
                            <th>连接：</th>
                            <td><input class="form-control" type="text" name="url"> 输入/控制器/方法即可 例如 /Nav/index
                            </td>
                        </tr>
                        <tr>
                            <th>控制器：</th>
                            <td><input class="form-control" type="text" name="controller"> 方法即可 例如 nav
                            </td>
                        </tr>
                        <tr>
                            <th>状态：</th>
                            <td><input class="form-control" type="text" name="status"> 显示(1)/隐藏(0)
                            </td>
                        </tr>
                        <tr>
                            <th>图标：</th>
                            <td><input class="form-control" type="text" name="icon"> glyphicon图标 输入 glyphicon-后边的即可</td>
                        </tr>
                        <tr>
                            <th></th>
                            <td><input class="btn btn-success" type="submit" value="添加"></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="bjy-edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times;</button>
                <h4 class="modal-title" id="myModalLabel"> 修改菜单</h4></div>
            <div class="modal-body">
                <form id="bjy-form" class="form-inline" action="{$smarty.const.__MODULE__}/Nav/edit" method="post"><input
                        type="hidden" name="id">
                    <table class="table table-striped table-bordered table-hover table-condensed">
                        <tr>
                            <th width="12%">菜单名：</th>
                            <td><input class="form-control" type="text" name="name"></td>
                        </tr>
                        <tr>
                            <th>连接：</th>
                            <td><input class="form-control" type="text" name="url"> 输入/控制器/方法即可 例如 /Nav/index
                            </td>
                        </tr>
                        <tr>
                            <th>控制器：</th>
                            <td><input class="form-control" type="text" name="controller"> 方法即可 例如 nav
                            </td>
                        </tr>
                        <tr>
                            <th>状态：</th>
                            <td><input class="form-control" type="text" name="status"> 显示(1)/隐藏(0)
                            </td>
                        </tr>
                        <tr>
                            <th>图标：</th>
                            <td><input class="form-control" type="text" name="icon"> glyphicon图标 输入 glyphicon-后边的即可</td>
                        </tr>
                        <tr>
                            <th></th>
                            <td><input class="btn btn-success" type="submit" value="修改"></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
    </div>
</div>
</div></div>
<script src="{$smarty.const.STATIC_URL}/statics/base.js"></script>
<!--Basic Scripts-->
<script src="{$smarty.const.JS_URL}jquery-2.0.3.min.js"></script>
<script src="{$smarty.const.JS_URL}bootstrap.min.js"></script>

<!--Beyond Scripts-->
<script src="{$smarty.const.JS_URL}beyond.min.js"></script>


<!--Page Related Scripts-->
<!--Sparkline Charts Needed Scripts-->
<script src="{$smarty.const.JS_URL}charts/sparkline/jquery.sparkline.js"></script>
<script src="{$smarty.const.JS_URL}charts/sparkline/sparkline-init.js"></script>

<!--Easy Pie Charts Needed Scripts-->
<script src="{$smarty.const.JS_URL}charts/easypiechart/jquery.easypiechart.js"></script>
<script src="{$smarty.const.JS_URL}charts/easypiechart/easypiechart-init.js"></script>

<!--Flot Charts Needed Scripts-->
<script src="{$smarty.const.JS_URL}charts/flot/jquery.flot.js"></script>
<script src="{$smarty.const.JS_URL}charts/flot/jquery.flot.resize.js"></script>
<script src="{$smarty.const.JS_URL}charts/flot/jquery.flot.pie.js"></script>
<script src="{$smarty.const.JS_URL}charts/flot/jquery.flot.tooltip.js"></script>
<script src="{$smarty.const.JS_URL}charts/flot/jquery.flot.orderBars.js"></script>
<script src="{$smarty.const.STATIC_URL}/statics/iCheck-1.0.2/icheck.min.js"></script>
<script>
    // 添加菜单
    function add() {
        $("input[name='name'],input[name='url'],input[name='controller'],input[name='status']").val('');
        $("input[name='pid']").val(0);
        $('#bjy-add').modal('show');
    }

    // 添加子菜单
    function add_child(obj) {
        var navId = $(obj).attr('navId');
        $("input[name='pid']").val(navId);
        $("input[name='name']").val('');
        $("input[name='status']").val('');
        $("input[name='url']").val('');
        $("input[name='icon']").val('');
        $("input[name='controller']").val('');
        $('#bjy-add').modal('show');
    }

    // 修改菜单
    function edit(obj) {
        var navId = $(obj).attr('navId');
        var navName = $(obj).attr('navName');
        var navStatus = $(obj).attr('navStatus');
        var navMca = $(obj).attr('navMca');
        var navIco = $(obj).attr('navIco');
        var controller = $(obj).attr('controller');
        $("input[name='id']").val(navId);
        $("input[name='controller']").val(controller);
        $("input[name='name']").val(navName);
        $("input[name='status']").val(navStatus);
        $("input[name='url']").val(navMca);
        $("input[name='icon']").val(navIco);
        $('#bjy-edit').modal('show');
    }

</script>
</body>
</html>